1
/****************************** Module Header ******************************\
2 * Module Name: HTMLDocumentEventHelper.cs
3 * Project: CSBrowserHelperObject
4 * Copyright (c) Microsoft Corporation.
6 * This ComVisible class HTMLDocumentEventHelper is used to set the event handler
7 * of the HTMLDocument. The interface DispHTMLDocument defines many events like
8 * oncontextmenu, onclick and so on, and these events could be set to an
9 * HTMLEventHandler instance.
12 * This source is subject to the Microsoft Public License.
13 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
14 * All other rights reserved.
16 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
17 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
19 \***************************************************************************/
21 using System
.Runtime
.InteropServices
;
24 namespace CSBrowserHelperObject
27 public class HTMLDocumentEventHelper
29 private HTMLDocument document
;
31 public HTMLDocumentEventHelper(HTMLDocument document
)
33 this.document
= document
;
36 public event HtmlEvent oncontextmenu
40 DispHTMLDocument dispDoc
= this.document
as DispHTMLDocument
;
42 object existingHandler
= dispDoc
.oncontextmenu
;
43 HTMLEventHandler handler
= existingHandler
is HTMLEventHandler
?
44 existingHandler
as HTMLEventHandler
:
45 new HTMLEventHandler(this.document
);
47 // Set the handler to the oncontextmenu event.
48 dispDoc
.oncontextmenu
= handler
;
50 handler
.eventHandler
+= value;
54 DispHTMLDocument dispDoc
= this.document
as DispHTMLDocument
;
55 object existingHandler
= dispDoc
.oncontextmenu
;
57 HTMLEventHandler handler
= existingHandler
is HTMLEventHandler
?
58 existingHandler
as HTMLEventHandler
: null;
61 handler
.eventHandler
-= value;